<template>
  <div>
    <el-dialog title="审核" :visible.sync="show" width="30%" @close="closeFn">
      <el-form
        :model="form"
        :rules="rules"
        ref="form"
        label-width="80px"
        :inline="false"
        size="normal"
      >
        <el-form-item style="margin-left:0" prop="chkState">
                <el-radio v-model="form.chkState" :label="2">通过</el-radio>
            <el-radio v-model="form.chkState" :label="3">拒绝</el-radio>

        </el-form-item>
        <el-form-item style="margin-left:0" prop="chkRemarks">
            <el-input
            type="textarea"
            :rows="2"
            placeholder="请输入审核意见"
            v-model="form.chkRemarks"
          >
          </el-input>
        </el-form-item>

      </el-form>

      <span slot="footer">
        <el-button @click="closeFn">取消</el-button>
        <el-button type="primary" @click="okFn">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  data () {
    return {
      show: false,
      form: {

        id: '', // 数据id
        chkRemarks: '', // 原因
        chkState: '' // 审核是否通过
      },
      rules: {
        chkState: [
          { required: true, message: '请选择', trigger: 'change' }
        ],
        chkRemarks: [
          { required: true, message: '请输入信息', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    showFn (id) {
      this.form.id = id
      this.show = true
      console.log(this.form)
    },
    // 弹窗关闭事件==================================清空form
    closeFn () {
      this.show = false
      this.form = {
        id: '', // 数据id
        chkRemarks: '', // 原因
        chkState: '' // 审核是否通过
      }
    },
    // 确认按钮=========================================
    okFn () {
      this.$refs.form.validate(async (vai) => {
        if (vai) {
          await choiceCheck(this.form)
          this.$message.success('上传成功')
          this.closeFn()
          this.$parent.getchoiceFn()
        }
      })
    }

  }
}
</script>

<style lang="scss" scoped>
::v-deep .el-form-item{
    .el-form-item__content{
        margin-left: 10px !important;
    }
}
</style>
